using System;
using System.Collections;
using System.Reflection;

namespace DynamicProxy
{
	public class MetaDataFactory
	{
		private static Hashtable typeMap = new Hashtable();

		private MetaDataFactory()
		{
		}

		public static void Add(Type interfaceType)
		{
			if (interfaceType != null)
			{
				lock (typeMap.SyncRoot)
				{
					if (!typeMap.ContainsKey(interfaceType.FullName))
					{
						typeMap.Add(interfaceType.FullName, interfaceType);
					}
				}
			}
		}

		public static MethodInfo GetMethod(string name, int i)
		{
			Type type = null;
			lock (typeMap.SyncRoot)
			{
				type = (Type)typeMap[name];
			}
			return type.GetMethods()[i];
		}

		public static PropertyInfo GetProperty(string name, int i)
		{
			Type type = null;
			lock (typeMap.SyncRoot)
			{
				type = (Type)typeMap[name];
			}
			return type.GetProperties()[i];
		}
	}
}
